package algorithms.greedy


import org.junit.jupiter.api.Assertions.assertTimeoutPreemptively
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.CsvSource
import redirectSystemIn
import redirectSystemOut
import java.time.Duration
import java.util.*
import kotlin.test.assertEquals

class ReverseShuffleMergeTests {
    @Test
    fun reverseShuffleMergeTest() {
        redirectSystemIn(this.javaClass) {
            val scan = Scanner(System.`in`)
            redirectSystemOut { expectedList ->
                while (scan.hasNextLine()) {
                    val s = scan.nextLine()

                    val result = reverseShuffleMerge(s)

                    println(result)
                    expectedList.add(scan.nextLine().trim())
                }
            }
        }
    }


    @ParameterizedTest
    @CsvSource(
        "aeiouuoiea, eaid"
        , "eggegg, egg"
        , "bdabaceadaedaaaeaecdeadababdbeaeeacacaba, aaaaaabaaceededecbdb"
    )
    fun reverseShuffleMergeZTest(s: String, expected: String) {
        assertTimeoutPreemptively(Duration.ofSeconds(10L)) {
            assertEquals(expected, reverseShuffleMerge(s))
        }
    }
}